home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsRuleNode.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  28KB  |  649 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla Communicator client code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Original Author: David W. Hyatt (hyatt@netscape.com)
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #ifndef nsRuleNode_h___
  40. #define nsRuleNode_h___
  41.  
  42. #include "nsPresContext.h"
  43. #include "nsStyleStruct.h"
  44.  
  45. class nsStyleContext;
  46. struct nsRuleList;
  47. struct PLDHashTable;
  48. class nsILanguageAtomService;
  49. struct nsRuleData;
  50. class nsIStyleRule;
  51. struct nsCSSStruct;
  52. // Copy of typedef that's in nsCSSStruct.h, for compilation speed.
  53. typedef nsCSSStruct nsRuleDataStruct;
  54.  
  55. struct nsRuleDataFont;
  56. class nsCSSValue;
  57.  
  58. typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
  59.  
  60. struct nsInheritedStyleData
  61. {
  62.  
  63. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
  64.   nsStyle##name * m##name##Data;
  65. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
  66.  
  67. #include "nsStyleStructList.h"
  68.  
  69. #undef STYLE_STRUCT_INHERITED
  70. #undef STYLE_STRUCT_RESET
  71.  
  72.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  73.     return aContext->AllocateFromShell(sz);
  74.   };
  75.  
  76.   void ClearInheritedData(PRUint32 aBits) {
  77. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
  78.     if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
  79.       m##name##Data = nsnull;
  80. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
  81.  
  82. #include "nsStyleStructList.h"
  83.  
  84. #undef STYLE_STRUCT_INHERITED
  85. #undef STYLE_STRUCT_RESET
  86.   };
  87.  
  88.   void Destroy(PRUint32 aBits, nsPresContext* aContext) {
  89. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
  90.     if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
  91.       m##name##Data->Destroy(aContext);
  92. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
  93.  
  94. #include "nsStyleStructList.h"
  95.  
  96. #undef STYLE_STRUCT_INHERITED
  97. #undef STYLE_STRUCT_RESET
  98.  
  99.     aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
  100.   };
  101.  
  102.   nsInheritedStyleData() {
  103. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
  104.     m##name##Data = nsnull;
  105. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
  106.  
  107. #include "nsStyleStructList.h"
  108.  
  109. #undef STYLE_STRUCT_INHERITED
  110. #undef STYLE_STRUCT_RESET
  111.  
  112.   };
  113. };
  114.  
  115. struct nsResetStyleData
  116. {
  117.   nsResetStyleData()
  118.   {
  119. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
  120.     m##name##Data = nsnull;
  121. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
  122.  
  123. #include "nsStyleStructList.h"
  124.  
  125. #undef STYLE_STRUCT_RESET
  126. #undef STYLE_STRUCT_INHERITED
  127.   };
  128.  
  129.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  130.     return aContext->AllocateFromShell(sz);
  131.   }
  132.  
  133.   void ClearInheritedData(PRUint32 aBits) {
  134. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
  135.     if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
  136.       m##name##Data = nsnull;
  137. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
  138.  
  139. #include "nsStyleStructList.h"
  140.  
  141. #undef STYLE_STRUCT_RESET
  142. #undef STYLE_STRUCT_INHERITED
  143.   };
  144.  
  145.   void Destroy(PRUint32 aBits, nsPresContext* aContext) {
  146. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
  147.     if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
  148.       m##name##Data->Destroy(aContext);
  149. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
  150.  
  151. #include "nsStyleStructList.h"
  152.  
  153. #undef STYLE_STRUCT_RESET
  154. #undef STYLE_STRUCT_INHERITED
  155.  
  156.     aContext->FreeToShell(sizeof(nsResetStyleData), this);
  157.   };
  158.  
  159. #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
  160.   nsStyle##name * m##name##Data;
  161. #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
  162.  
  163. #include "nsStyleStructList.h"
  164.  
  165. #undef STYLE_STRUCT_RESET
  166. #undef STYLE_STRUCT_INHERITED
  167.  
  168. };
  169.  
  170. struct nsCachedStyleData
  171. {
  172.   struct StyleStructInfo {
  173.     ptrdiff_t mCachedStyleDataOffset;
  174.     ptrdiff_t mInheritResetOffset;
  175.     PRBool    mIsReset;
  176.   };
  177.  
  178.   static StyleStructInfo gInfo[];
  179.  
  180.   nsInheritedStyleData* mInheritedData;
  181.   nsResetStyleData* mResetData;
  182.  
  183.   static PRBool IsReset(const nsStyleStructID& aSID) {
  184.     return gInfo[aSID].mIsReset;
  185.   };
  186.  
  187.   static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
  188.     return 1 << aSID;
  189.   };
  190.  
  191.   NS_HIDDEN_(nsStyleStruct*) NS_FASTCALL GetStyleData(const nsStyleStructID& aSID) {
  192.     // Each struct is stored at this.m##type##Data->m##name##Data where
  193.     // |type| is either Inherit or Reset, and |name| is the name of the
  194.     // style struct.  The |gInfo| stores the offset of the appropriate
  195.     // m##type##Data for the struct within nsCachedStyleData (|this|)
  196.     // and the offset of the appropriate m##name##Data within the
  197.     // m##type##Data.  Note that if we don't have any reset structs,
  198.     // then mResetData is null, and likewise for mInheritedData.  This
  199.     // saves us from having to go through the long if-else cascade into
  200.     // which most compilers will turn a case statement.
  201.  
  202.     // NOTE:  nsStyleContext::SetStyle works roughly the same way.
  203.  
  204.     const StyleStructInfo& info = gInfo[aSID];
  205.  
  206.     // Get either &mInheritedData or &mResetData.
  207.     char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
  208.  
  209.     // Get either mInheritedData or mResetData.
  210.     char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
  211.  
  212.     nsStyleStruct* data = nsnull;
  213.     if (resetOrInherit) {
  214.       // If we have the mInheritedData or mResetData, then we might have
  215.       // the struct, so get it.
  216.       char* dataSlot = resetOrInherit + info.mInheritResetOffset;
  217.       data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
  218.     }
  219.     return data;
  220.   };
  221.  
  222.   NS_HIDDEN_(void) ClearInheritedData(PRUint32 aBits) {
  223.     if (mResetData)
  224.       mResetData->ClearInheritedData(aBits);
  225.     if (mInheritedData)
  226.       mInheritedData->ClearInheritedData(aBits);
  227.   }
  228.  
  229.   NS_HIDDEN_(void) Destroy(PRUint32 aBits, nsPresContext* aContext) {
  230.     if (mResetData)
  231.       mResetData->Destroy(aBits, aContext);
  232.     if (mInheritedData)
  233.       mInheritedData->Destroy(aBits, aContext);
  234.     mResetData = nsnull;
  235.     mInheritedData = nsnull;
  236.   }
  237.  
  238.   nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {};
  239.   ~nsCachedStyleData() {};
  240. };
  241.  
  242. /**
  243.  * nsRuleNode is a node in a lexicographic tree (the "rule tree")
  244.  * indexed by style rules (implementations of nsIStyleRule).
  245.  *
  246.  * The rule tree is owned by the nsStyleSet and is destroyed when the
  247.  * presentation of the document goes away.  It is garbage-collected
  248.  * (using mark-and-sweep garbage collection) during the lifetime of the
  249.  * document (when dynamic changes cause the destruction of enough style
  250.  * contexts).  Rule nodes are marked if they are pointed to by a style
  251.  * context or one of their descendants is.
  252.  *
  253.  * An nsStyleContext, which represents the computed style data for an
  254.  * element, points to an nsRuleNode.  The path from the root of the rule
  255.  * tree to the nsStyleContext's mRuleNode gives the list of the rules
  256.  * matched, from least important in the cascading order to most
  257.  * important in the cascading order.
  258.  *
  259.  * The reason for using a lexicographic tree is that it allows for
  260.  * sharing of style data, which saves both memory (for storing the
  261.  * computed style data) and time (for computing them).  This sharing
  262.  * depends on the computed style data being stored in structs (nsStyle*)
  263.  * that contain only properties that are inherited by default
  264.  * ("inherited structs") or structs that contain only properties that
  265.  * are not inherited by default ("reset structs").  The optimization
  266.  * depends on the normal case being that style rules specify relatively
  267.  * few properties and even that elements generally have relatively few
  268.  * properties specified.  This allows sharing in the following ways:
  269.  *   1. [mainly reset structs] When a style data struct will contain the
  270.  *      same computed value for any elements that match the same set of
  271.  *      rules (common for reset structs), it can be stored on the
  272.  *      nsRuleNode instead of on the nsStyleContext.
  273.  *   2. [only? reset structs] When (1) occurs, and an nsRuleNode doesn't
  274.  *      have any rules that change the values in the struct, the
  275.  *      nsRuleNode can share that struct with its parent nsRuleNode.
  276.  *   3. [mainly inherited structs] When an element doesn't match any
  277.  *      rules that change the value of a property (or, in the edge case,
  278.  *      when all the values specified are 'inherit'), the nsStyleContext
  279.  *      can use the same nsStyle* struct as its parent nsStyleContext.
  280.  *
  281.  * Since the data represented by an nsIStyleRule are immutable, the data
  282.  * represented by an nsRuleNode are also immutable (with a few
  283.  * exceptions, like system color changes).
  284.  */
  285.  
  286. class nsRuleNode {
  287. public:
  288.     // for purposes of the RuleDetail (and related code),
  289.     //  * a non-inherited value is one that is specified as a
  290.     //    non-"inherit" value or as an "inherit" value that is reflected
  291.     //    in the struct and to the user of the style system with an
  292.     //    eCSSUnit_Inherit value
  293.     //  * an inherited value is one that is specified as "inherit" and
  294.     //    where the inheritance is computed by the style system
  295.   enum RuleDetail {
  296.     eRuleNone, // No props have been specified at all.
  297.     eRulePartialReset, // At least one prop with a non-inherited value
  298.                        // has been specified.  No props have been
  299.                        // specified with an inherited value.  At least
  300.                        // one prop remains unspecified.
  301.     eRulePartialMixed, // At least one prop with a non-inherited value
  302.                        // has been specified.  Some props may also have
  303.                        // been specified with an inherited value.  At
  304.                        // least one prop remains unspecified.
  305.     eRulePartialInherited, // Only props with inherited values have
  306.                            // have been specified.  At least one prop
  307.                            // remains unspecified.
  308.     eRuleFullReset, // All props have been specified.  None has an
  309.                     // inherited value.
  310.     eRuleFullMixed, // All props have been specified.  At least one has
  311.                     // a non-inherited value.
  312.     eRuleFullInherited, // All props have been specified with inherited
  313.                         // values.
  314.     eRuleUnknown // Information unknown (used as a result from a check
  315.                  // callback to trigger the normal checking codepath)
  316.   };
  317.  
  318. private:
  319.   nsPresContext* mPresContext; // Our pres context.
  320.  
  321.   nsRuleNode* mParent; // A pointer to the parent node in the tree.
  322.                        // This enables us to walk backwards from the
  323.                        // most specific rule matched to the least
  324.                        // specific rule (which is the optimal order to
  325.                        // use for lookups of style properties.
  326.   nsIStyleRule* mRule; // [STRONG] A pointer to our specific rule.
  327.  
  328.   // The children of this node are stored in either a hashtable or list
  329.   // that maps from rules to our nsRuleNode children.  When matching
  330.   // rules, we use this mapping to transition from node to node
  331.   // (constructing new nodes as needed to flesh out the tree).
  332.  
  333.   void *mChildrenTaggedPtr; // Accessed only through the methods below.
  334.  
  335.   enum {
  336.     kTypeMask = 0x1,
  337.     kListType = 0x0,
  338.     kHashType = 0x1
  339.   };
  340.   enum {
  341.     // Maximum to have in a list before converting to a hashtable.
  342.     // XXX Need to optimize this.
  343.     kMaxChildrenInList = 32
  344.   };
  345.  
  346.   PRBool HaveChildren() {
  347.     return mChildrenTaggedPtr != nsnull;
  348.   }
  349.   PRBool ChildrenAreHashed() {
  350.     return (PRWord(mChildrenTaggedPtr) & kTypeMask) == kHashType;
  351.   }
  352.   nsRuleList* ChildrenList() {
  353.     return NS_REINTERPRET_CAST(nsRuleList*, mChildrenTaggedPtr);
  354.   }
  355.   nsRuleList** ChildrenListPtr() {
  356.     return NS_REINTERPRET_CAST(nsRuleList**, &mChildrenTaggedPtr);
  357.   }
  358.   PLDHashTable* ChildrenHash() {
  359.     return (PLDHashTable*) (PRWord(mChildrenTaggedPtr) & ~PRWord(kTypeMask));
  360.   }
  361.   void SetChildrenList(nsRuleList *aList) {
  362.     NS_ASSERTION(!(PRWord(aList) & kTypeMask),
  363.                  "pointer not 2-byte aligned");
  364.     mChildrenTaggedPtr = aList;
  365.   }
  366.   void SetChildrenHash(PLDHashTable *aHashtable) {
  367.     NS_ASSERTION(!(PRWord(aHashtable) & kTypeMask),
  368.                  "pointer not 2-byte aligned");
  369.     mChildrenTaggedPtr = (void*)(PRWord(aHashtable) | kHashType);
  370.   }
  371.   void ConvertChildrenToHash();
  372.  
  373.   nsCachedStyleData mStyleData;   // Any data we cached on the rule node.
  374.  
  375.   PRUint32 mDependentBits; // Used to cache the fact that we can look up
  376.                            // cached data under a parent rule.
  377.  
  378.   PRUint32 mNoneBits; // Used to cache the fact that the branch to this
  379.                       // node specifies no non-inherited data for a
  380.                       // given struct type.  (This usually implies that
  381.                       // the entire branch specifies no non-inherited
  382.                       // data, although not necessarily, if a
  383.                       // non-inherited value is overridden by an
  384.                       // explicit 'inherit' value.)  For example, if an
  385.                       // entire rule branch specifies no color
  386.                       // information, then a bit will be set along every
  387.                       // rule node on that branch, so that you can break
  388.                       // out of the rule tree early and just inherit
  389.                       // from the parent style context.  The presence of
  390.                       // this bit means we should just get inherited
  391.                       // data from the parent style context, and it is
  392.                       // never used for reset structs since their
  393.                       // Compute*Data functions don't initialize from
  394.                       // inherited data.
  395.  
  396. friend struct nsRuleList;
  397.  
  398. public:
  399.   // Overloaded new operator. Initializes the memory to 0 and relies on an arena
  400.   // (which comes from the presShell) to perform the allocation.
  401.   NS_HIDDEN_(void*) operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
  402.   NS_HIDDEN_(void) Destroy();
  403.   static NS_HIDDEN_(nsILanguageAtomService*) gLangService;
  404.  
  405. protected:
  406.   NS_HIDDEN_(void) PropagateDependentBit(PRUint32 aBit,
  407.                                          nsRuleNode* aHighestNode);
  408.   NS_HIDDEN_(void) PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
  409.   
  410.   NS_HIDDEN_(const nsStyleStruct*) SetDefaultOnRoot(const nsStyleStructID aSID,
  411.                                                     nsStyleContext* aContext);
  412.  
  413.   NS_HIDDEN_(const nsStyleStruct*)
  414.     WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext, 
  415.                  nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData);
  416.  
  417.   NS_HIDDEN_(const nsStyleStruct*)
  418.     ComputeDisplayData(nsStyleStruct* aStartDisplay,
  419.                        const nsRuleDataStruct& aDisplayData,
  420.                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
  421.                        const RuleDetail& aRuleDetail, PRBool aInherited);
  422.  
  423.   NS_HIDDEN_(const nsStyleStruct*)
  424.     ComputeVisibilityData(nsStyleStruct* aStartVisibility,
  425.                           const nsRuleDataStruct& aDisplayData,
  426.                           nsStyleContext* aContext, nsRuleNode* aHighestNode,
  427.                           const RuleDetail& aRuleDetail, PRBool aInherited);
  428.  
  429.   NS_HIDDEN_(const nsStyleStruct*)
  430.     ComputeFontData(nsStyleStruct* aStartFont,
  431.                     const nsRuleDataStruct& aFontData,
  432.                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
  433.                     const RuleDetail& aRuleDetail, PRBool aInherited);
  434.  
  435.   NS_HIDDEN_(const nsStyleStruct*)
  436.     ComputeColorData(nsStyleStruct* aStartColor,
  437.                      const nsRuleDataStruct& aColorData,
  438.                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
  439.                      const RuleDetail& aRuleDetail, PRBool aInherited);
  440.  
  441.   NS_HIDDEN_(const nsStyleStruct*)
  442.     ComputeBackgroundData(nsStyleStruct* aStartBackground,
  443.                           const nsRuleDataStruct& aColorData, 
  444.                           nsStyleContext* aContext, nsRuleNode* aHighestNode,
  445.                           const RuleDetail& aRuleDetail, PRBool aInherited);
  446.  
  447.   NS_HIDDEN_(const nsStyleStruct*)
  448.     ComputeMarginData(nsStyleStruct* aStartMargin,
  449.                       const nsRuleDataStruct& aMarginData, 
  450.                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
  451.                       const RuleDetail& aRuleDetail, PRBool aInherited);
  452.  
  453.   NS_HIDDEN_(const nsStyleStruct*)
  454.     ComputeBorderData(nsStyleStruct* aStartBorder,
  455.                       const nsRuleDataStruct& aMarginData, 
  456.                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
  457.                       const RuleDetail& aRuleDetail, PRBool aInherited);
  458.  
  459.   NS_HIDDEN_(const nsStyleStruct*)
  460.     ComputePaddingData(nsStyleStruct* aStartPadding,
  461.                        const nsRuleDataStruct& aMarginData, 
  462.                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
  463.                        const RuleDetail& aRuleDetail, PRBool aInherited);
  464.  
  465.   NS_HIDDEN_(const nsStyleStruct*)
  466.     ComputeOutlineData(nsStyleStruct* aStartOutline,
  467.                        const nsRuleDataStruct& aMarginData, 
  468.                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
  469.                        const RuleDetail& aRuleDetail, PRBool aInherited);
  470.  
  471.   NS_HIDDEN_(const nsStyleStruct*)
  472.     ComputeListData(nsStyleStruct* aStartList,
  473.                     const nsRuleDataStruct& aListData,
  474.                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
  475.                     const RuleDetail& aRuleDetail, PRBool aInherited);
  476.  
  477.   NS_HIDDEN_(const nsStyleStruct*)
  478.     ComputePositionData(nsStyleStruct* aStartPosition,
  479.                         const nsRuleDataStruct& aPositionData, 
  480.                         nsStyleContext* aContext, nsRuleNode* aHighestNode,
  481.                         const RuleDetail& aRuleDetail, PRBool aInherited);
  482.  
  483.   NS_HIDDEN_(const nsStyleStruct*)
  484.     ComputeTableData(nsStyleStruct* aStartTable,
  485.                      const nsRuleDataStruct& aTableData, 
  486.                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
  487.                      const RuleDetail& aRuleDetail, PRBool aInherited);
  488.  
  489.   NS_HIDDEN_(const nsStyleStruct*)
  490.     ComputeTableBorderData(nsStyleStruct* aStartTable,
  491.                            const nsRuleDataStruct& aTableData, 
  492.                            nsStyleContext* aContext, nsRuleNode* aHighestNode,
  493.                            const RuleDetail& aRuleDetail, PRBool aInherited);
  494.  
  495.   NS_HIDDEN_(const nsStyleStruct*)
  496.     ComputeContentData(nsStyleStruct* aStartContent,
  497.                        const nsRuleDataStruct& aData,
  498.                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
  499.                        const RuleDetail& aRuleDetail, PRBool aInherited);
  500.  
  501.   NS_HIDDEN_(const nsStyleStruct*)
  502.     ComputeQuotesData(nsStyleStruct* aStartQuotes,
  503.                       const nsRuleDataStruct& aData, 
  504.                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
  505.                       const RuleDetail& aRuleDetail, PRBool aInherited);
  506.  
  507.   NS_HIDDEN_(const nsStyleStruct*)
  508.     ComputeTextData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, 
  509.                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
  510.                     const RuleDetail& aRuleDetail, PRBool aInherited);
  511.  
  512.   NS_HIDDEN_(const nsStyleStruct*)
  513.     ComputeTextResetData(nsStyleStruct* aStartData,
  514.                          const nsRuleDataStruct& aData,
  515.                          nsStyleContext* aContext, nsRuleNode* aHighestNode,
  516.                          const RuleDetail& aRuleDetail, PRBool aInherited);
  517.  
  518.   NS_HIDDEN_(const nsStyleStruct*)
  519.     ComputeUserInterfaceData(nsStyleStruct* aStartData,
  520.                              const nsRuleDataStruct& aData, 
  521.                              nsStyleContext* aContext,
  522.                              nsRuleNode* aHighestNode,
  523.                              const RuleDetail& aRuleDetail, PRBool aInherited);
  524.  
  525.   NS_HIDDEN_(const nsStyleStruct*)
  526.     ComputeUIResetData(nsStyleStruct* aStartData,
  527.                        const nsRuleDataStruct& aData,
  528.                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
  529.                        const RuleDetail& aRuleDetail, PRBool aInherited);
  530.  
  531.   NS_HIDDEN_(const nsStyleStruct*)
  532.     ComputeXULData(nsStyleStruct* aStartXUL, const nsRuleDataStruct& aXULData, 
  533.                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
  534.                    const RuleDetail& aRuleDetail, PRBool aInherited);
  535.  
  536.   NS_HIDDEN_(const nsStyleStruct*)
  537.     ComputeColumnData(nsStyleStruct* aStartColumn, const nsRuleDataStruct& aColumnData,
  538.                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
  539.                       const RuleDetail& aRuleDetail, PRBool aInherited);
  540.  
  541. #ifdef MOZ_SVG
  542.   NS_HIDDEN_(const nsStyleStruct*)
  543.     ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData, 
  544.                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
  545.                    const RuleDetail& aRuleDetail, PRBool aInherited);
  546.  
  547.   NS_HIDDEN_(const nsStyleStruct*)
  548.     ComputeSVGResetData(nsStyleStruct* aStartSVG,
  549.                         const nsRuleDataStruct& aSVGData, 
  550.                         nsStyleContext* aContext, nsRuleNode* aHighestNode,
  551.                         const RuleDetail& aRuleDetail, PRBool aInherited);
  552. #endif
  553.  
  554.   // helpers for |ComputeFontData| that need access to |mNoneBits|:
  555.   static NS_HIDDEN_(void) SetFont(nsPresContext* aPresContext,
  556.                                   nsStyleContext* aContext,
  557.                                   nscoord aMinFontSize,
  558.                                   PRBool aUseDocumentFonts,
  559.                                   PRBool aIsGeneric,
  560.                                   const nsRuleDataFont& aFontData,
  561.                                   const nsFont& aDefaultFont,
  562.                                   const nsStyleFont* aParentFont,
  563.                                   nsStyleFont* aFont, PRBool& aInherited);
  564.  
  565.   static NS_HIDDEN_(void) SetGenericFont(nsPresContext* aPresContext,
  566.                                          nsStyleContext* aContext,
  567.                                          const nsRuleDataFont& aFontData,
  568.                                          PRUint8 aGenericFontID,
  569.                                          nscoord aMinFontSize,
  570.                                          PRBool aUseDocumentFonts,
  571.                                          nsStyleFont* aFont);
  572.  
  573.   NS_HIDDEN_(void) AdjustLogicalBoxProp(nsStyleContext* aContext,
  574.                                         const nsCSSValue& aLTRSource,
  575.                                         const nsCSSValue& aRTLSource,
  576.                                         const nsCSSValue& aLTRLogicalValue,
  577.                                         const nsCSSValue& aRTLLogicalValue,
  578.                                         const nsStyleSides& aParentRect,
  579.                                         nsStyleSides& aRect,
  580.                                         PRUint8 aSide,
  581.                                         PRInt32 aMask,
  582.                                         PRBool& aInherited);
  583.   
  584.   inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsRuleDataStruct& aRuleDataStruct);
  585.  
  586.   NS_HIDDEN_(const nsStyleStruct*) GetParentData(const nsStyleStructID aSID);
  587.   NS_HIDDEN_(const nsStyleStruct*) GetDisplayData(nsStyleContext* aContext);
  588.   NS_HIDDEN_(const nsStyleStruct*) GetVisibilityData(nsStyleContext* aContext);
  589.   NS_HIDDEN_(const nsStyleStruct*) GetFontData(nsStyleContext* aContext);
  590.   NS_HIDDEN_(const nsStyleStruct*) GetColorData(nsStyleContext* aContext);
  591.   NS_HIDDEN_(const nsStyleStruct*) GetBackgroundData(nsStyleContext* aContext);
  592.   NS_HIDDEN_(const nsStyleStruct*) GetMarginData(nsStyleContext* aContext);
  593.   NS_HIDDEN_(const nsStyleStruct*) GetBorderData(nsStyleContext* aContext);
  594.   NS_HIDDEN_(const nsStyleStruct*) GetPaddingData(nsStyleContext* aContext);
  595.   NS_HIDDEN_(const nsStyleStruct*) GetOutlineData(nsStyleContext* aContext);
  596.   NS_HIDDEN_(const nsStyleStruct*) GetListData(nsStyleContext* aContext);
  597.   NS_HIDDEN_(const nsStyleStruct*) GetPositionData(nsStyleContext* aContext);
  598.   NS_HIDDEN_(const nsStyleStruct*) GetTableData(nsStyleContext* aContext);
  599.   NS_HIDDEN_(const nsStyleStruct*)
  600.     GetTableBorderData(nsStyleContext* aContext);
  601.  
  602.   NS_HIDDEN_(const nsStyleStruct*) GetContentData(nsStyleContext* aContext);
  603.   NS_HIDDEN_(const nsStyleStruct*) GetQuotesData(nsStyleContext* aContext);
  604.   NS_HIDDEN_(const nsStyleStruct*) GetTextData(nsStyleContext* aContext);
  605.   NS_HIDDEN_(const nsStyleStruct*) GetTextResetData(nsStyleContext* aContext);
  606.   NS_HIDDEN_(const nsStyleStruct*)
  607.     GetUserInterfaceData(nsStyleContext* aContext);
  608.  
  609.   NS_HIDDEN_(const nsStyleStruct*) GetUIResetData(nsStyleContext* aContext);
  610.   NS_HIDDEN_(const nsStyleStruct*) GetXULData(nsStyleContext* aContext);
  611.   NS_HIDDEN_(const nsStyleStruct*) GetColumnData(nsStyleContext* aContext);
  612. #ifdef MOZ_SVG
  613.   NS_HIDDEN_(const nsStyleStruct*) GetSVGData(nsStyleContext* aContext);
  614.   NS_HIDDEN_(const nsStyleStruct*) GetSVGResetData(nsStyleContext* aContext);
  615. #endif
  616.  
  617. public:
  618.   nsRuleNode(nsPresContext* aPresContext, nsIStyleRule* aRule,
  619.              nsRuleNode* aParent) NS_HIDDEN;
  620.   virtual ~nsRuleNode() NS_HIDDEN;
  621.  
  622.   static NS_HIDDEN_(nsRuleNode*) CreateRootNode(nsPresContext* aPresContext);
  623.  
  624.   NS_HIDDEN_(nsresult) Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
  625.   nsRuleNode* GetParent() const { return mParent; }
  626.   PRBool IsRoot() const { return mParent == nsnull; }
  627.  
  628.   // NOTE:  Does not |AddRef|.
  629.   nsIStyleRule* GetRule() const { return mRule; }
  630.   // NOTE: Does not |AddRef|.
  631.   nsPresContext* GetPresContext() const { return mPresContext; }
  632.  
  633.   NS_HIDDEN_(nsresult) ClearStyleData();
  634.   NS_HIDDEN_(const nsStyleStruct*) GetStyleData(nsStyleStructID aSID, 
  635.                                                 nsStyleContext* aContext,
  636.                                                 PRBool aComputeData);
  637.  
  638.   /*
  639.    * Garbage collection.  Mark walks up the tree, marking any unmarked
  640.    * ancestors until it reaches a marked one.  Sweep recursively sweeps
  641.    * the children, destroys any that are unmarked, and clears marks,
  642.    * returning true if the node on which it was called was destroyed.
  643.    */
  644.   NS_HIDDEN_(void) Mark();
  645.   NS_HIDDEN_(PRBool) Sweep();
  646. };
  647.  
  648. #endif
  649.